package com.sosv.breweryDB.connector.service.resource.style;

import javax.ws.rs.core.MultivaluedMap;

import com.google.inject.Inject;
import com.sosv.breweryDB.connector.configuration.IBreweryDBConnectorConfiguration;
import com.sosv.breweryDB.connector.entity.StyleResultPage;
import com.sosv.breweryDB.connector.service.exceptions.ApiKeyNotFoundExeption;
import com.sosv.breweryDB.connector.service.exceptions.ObjectNotFoundException;
import com.sosv.breweryDB.connector.service.resource.AbstractResource;
import com.sosv.breweryDB.connector.service.resource.filter.FilterMultivalueMapBuilder;
import com.sosv.breweryDB.connector.service.resource.filter.beer.IBeersFilter;
import com.sun.jersey.api.client.Client;

public class StyleResource  extends AbstractResource implements IStyleResource{
	
	@Inject
	public StyleResource(IBreweryDBConnectorConfiguration configuration,
			Client client) {
		super(configuration, client);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sosv.breweryDB.connector.service.resource.beer.IBeerResource#getBeers
	 * (java.lang.Integer)
	 */
	public StyleResultPage getStyles(Number currentPage, IBeersFilter filter)
			throws ApiKeyNotFoundExeption {
		MultivaluedMap<String, String> map = new FilterMultivalueMapBuilder()
				.convert(filter);
		StyleResultPage result = null;
		if (currentPage != null) {
			map.add("p", currentPage.toString());
		}
		try {
			result = get("styles/", map, new StyleResultPage());
		} catch (ObjectNotFoundException e) {
		}

		return result;
	}


}
